<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>原因管理</title>
    <%@ include file="/view/common/tags.jsp"%>
    <script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-body">
                    <div class="panel panel-default">
                        <div class="panel-body" style="padding-bottom:5px;">
                            <form class="form-horizontal" action="" method="post" id="dataForm">
                                <input type="hidden" id="token" name="token" value=""/>
                                <div class="searchMenu" >
                                    <div>
                                        <label>类型：</label>
                                        <sk:select cssClass="form-control select" name="wm[REASON_TYPE_ID]" id="reasonTypeId" value="${page.wm.REASON_TYPE_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseType/select?wm[TYPE_FLAG]=60&wm[OPEN_FLAG]=1&wm[DEL_FLAG]=0">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div class="mal10" >
                                        <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                        <sk:button type="button" rightKey="20170816153140"  _class="btn btn-success btn-sm"  onclick="add()"><span class='glyphicon glyphicon-plus'></span>添&nbsp;加</sk:button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                        <thead>
                        <tr>
                            <th data-field="index" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
                            <th data-field="reasonTypeDes" data-align="center" data-sortable="true">类型</th>
                            <th data-field="reasonDes" data-align="center" data-sortable="true">内容</th>
                            <th data-field="useFlag" data-align="center" data-formatter="useFlagFormatter" data-sortable="true">是否开启</th>
                            <th data-field="optStaffAccount" data-align="center" data-sortable="true">操作人</th>
                            <th data-field="optTime" data-align="center" data-formatter="timeFormatter_point" data-sortable="true">操作时间</th>
                            <th data-field="deleteButton" data-align="center"  data-formatter="buttonFormatter" data-sortable="false">操作</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<%@ include file="/view/common/footer.jsp"%>
</body>
<script>
    // 提示信息
    var msgg='<%=request.getAttribute("msg")%>';
    if (msgg && msgg!=null && msgg!='null') {
        layer.msg(msgg);
    }
    var tableIndex = 0; // 添加修改的弹出框的ID

    // 加载table 数据
    $(function(){
        $("#token").val(sessionStorage.getItem("token"));

        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/pubgBaseReasons/data.json",
            method:"get",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })

    //查询
    function findData(){
        $("#dataTable").bootstrapTable("refresh",{} );
    }

    /*bootstrap table点击行事件*/
    $(function(){
        $("body").on("click","table>tbody>tr",function(){
            $(this).css("background","#e1ecf1").siblings().css("background","");
        });
    })

    // 是否开启
    function useFlagFormatter(value, row) {
        var html = "";
        if (row.useFlag == 1) {
            html = "<span class='text-success'>是 </span>";
        }else {
            html = "<span class='text-warning'>否 </span>";
        }
        return html;
    }

    // 操作按钮
    function buttonFormatter(value, row, index) {
        var caozuo2 = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
        return caozuo2 ;
    }

    // 弹出添加的窗口
    function add(){
        tableIndex = layer.open({
            type: 2,
            title: "添加原因",
            closeBtn: 1,
            shadeClose: true,
            area: ['450px', '280px'],
            content: "${sysManagerV1}/tradeReasons/toAdd?rowId=0",
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }

    // 弹出添加的窗口      修改功能
    function _update(rowId){
        tableIndex = layer.open({
            type: 2,
            title: "修改原因",
            closeBtn: 1,
            shadeClose: true,
            area: ['450px', '280px'],
            content: "${sysManagerV1}/tradeReasons/toAdd?rowId=" + rowId ,
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
</script>
</html>